import unittest
import HTMLTestRunner
import os
import time

# 存放测试报告的路径
report_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# 测试报告文件名
report_filename = time.strftime("front_shop_cart %Y-%m-%d %H-%M-%S") + '-HTMLReport.html'
# 最终生成测试报告文件的路径
html_report_path = os.path.join(report_path, "report", report_filename)
# 测试套件
loader = unittest.defaultTestLoader.discover("../case/front", 'test_shopcart.py')
with open(html_report_path, 'wb') as f:
    runner = HTMLTestRunner.HTMLTestRunner(
        tester='xiao',
        title='购物车',
        description='购物车自动化测试报告',
        stream=f,
        verbosity=2
    )
    runner.run(loader)
